package com.dubbo.service.impl;

import com.dubbo.IWeixin;
import com.dubbo.StaticConstants;
import com.dubbo.cache.ehcache.DecorateCacheManager;
import com.dubbo.dao.IWeixinDao;
import com.dubbo.service.IWeixinService;
import com.dubbo.zk.ZkClient;
import org.apache.zookeeper.CreateMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author Zhuyanfeng on 2018/3/20
 */
@Service
public class IWeixinServiceImpl implements IWeixinService {

    @Autowired
    private IWeixin iWeixin;


    @Autowired
    private DecorateCacheManager ehcacheManager;

    @Autowired
    private ZkClient zkClient;

    @Autowired
    private IWeixinDao iWeixinDao;

    public String getWeixinTicket(String appid, String secret) {
        ehcacheManager.put("aa","uuuuuuu",StaticConstants.EHCACHE_CURRENT_USER);
        Object aa = ehcacheManager.get("aa", StaticConstants.EHCACHE_CURRENT_USER);
        zkClient.create("/nodennnn", CreateMode.PERSISTENT,true);
        System.out.println(aa.toString());
        return iWeixinDao.getWeixinCredential(iWeixin.getTicket(appid, secret));
    }
}
